/******************************************************************************
 * The contents of this file are subject to the   JDI License  Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Initial Developer of the Original Code is 陈慧然. Portions created by 
 * 陈慧然 are Copyright 陈慧然.
 * All Rights Reserved.
 *
 *              Contact john_holen@163.com for licensing alternatives.
 *
 *****************************************************************************/


package org.peony.models;

import org.peony.standard.ui.event.SIDataEventManager;
import org.peony.tools.StringUtil;

/**
 *  定义显示Table中的列
 *
 *  @author     陈慧然
 *  @version    Id: Cols.java, v 0.000 2008-4-25 下午05:56:17 陈慧然 Exp
 */
public class MCol {
	private String showName = StringUtil.empty;				//显示名称
	private String id = StringUtil.empty;					//列ID
	private int seq = -1;									//列在行中的排列顺序
	private int type = -1;									//列的数据类型
	private boolean editable = false;						//列的可编辑性
	private boolean showable = true;						//列是否可以被显示
	private boolean nullable = true;						//是否可以为空
	private boolean hasOperate = false;						//是否具有针对该项的校验方法
	private boolean virtual = false;						//是否为虚拟字段
	private boolean isPK = false;							//是否为主键
	private SIDataEventManager dataManager;					//执行校验的对象
	private String tableId = StringUtil.empty;				//列所在的表
	private String name = StringUtil.empty;					//列名
	private boolean canBeSpaces = false;					//是否可以以空格开始或以空格结束
	private int maxLength = 10;								//列的最大长度
	private int minLength = 0;								//列的最小长度
	public static MCol getCols(String id){
		return null;
	}
	/**
	 * 构造方法
	 * @param showName 显示名称
	 * @param id ID
	 * @param seq 排序序号
	 */
	public MCol(String showName,String id,int seq){
		this.seq = seq;
		this.showName = showName;
		this.id = id;
	}
	/**
	 * 构造方法
	 * @param showName 显示名称
	 * @param id ID
	 */
	public MCol(String showName,String id){
		this.showName = showName;
		this.id = id;
	}
	public String getShowName() {
		return showName;
	}
	public void setShowName(String showName) {
		this.showName = showName;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public int getSeq() {
		return seq;
	}
	public void setSeq(int seq) {
		this.seq = seq;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public boolean isEditable() {
		return editable;
	}
	public void setEditable(boolean editable) {
		this.editable = editable;
	}
	public boolean isShowable() {
		return showable;
	}
	public void setShowable(boolean showable) {
		this.showable = showable;
	}
	public boolean isNullable() {
		return nullable;
	}
	public void setNullable(boolean nullable) {
		this.nullable = nullable;
	}
	public boolean isVirtual() {
		return virtual;
	}
	public void setVirtual(boolean virtual) {
		this.virtual = virtual;
	}
	public boolean isPK() {
		return isPK;
	}
	public void setPK(boolean isPK) {
		this.isPK = isPK;
	}
	public boolean isHasOperate() {
		return hasOperate;
	}
	public void setHasOperate(boolean hasOperate) {
		this.hasOperate = hasOperate;
	}
	public SIDataEventManager getDataManager() {
		return dataManager;
	}
	public void setDataManager(String dataManager) {
		try{
			this.dataManager = (SIDataEventManager)Class.forName(dataManager).newInstance();
		}catch(Exception e){
			dataManager = null;
		}
	}
	public String getTableId() {
		return tableId;
	}
	public void setTableId(String tableId) {
		this.tableId = tableId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setDataManager(SIDataEventManager dataManager) {
		this.dataManager = dataManager;
	}
	public boolean isCanBeSpaces() {
		return canBeSpaces;
	}
	public void setCanBeSpaces(boolean canBeSpaces) {
		this.canBeSpaces = canBeSpaces;
	}
	public int getMaxLength() {
		return maxLength;
	}
	public void setMaxLength(int maxLength) {
		this.maxLength = maxLength;
	}
	public int getMinLength() {
		return minLength;
	}
	public void setMinLength(int minLength) {
		this.minLength = minLength;
	}
	
}
